package com.letoken.platform.repo.app.po;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.time.LocalDateTime;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * app用户登陆日志记录表
 * </p>
 *
 * @author 作者
 * @since 2022-11-15
 */
@Getter
@Setter
@TableName("app_user_login_log")
@ApiModel(value = "AppUserLoginLog对象", description = "app用户登陆日志记录表")
public class AppUserLoginLog extends Model<AppUserLoginLog> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("登陆记录id")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("用户id")
    @TableField("app_user_id")
    private Integer appUserId;

    @ApiModelProperty("设备ID")
    @TableField("device_id")
    private String deviceId;
    @ApiModelProperty("设备源。IOS/ANDROID")
    @TableField("device_res")
    private String deviceRes;

    @ApiModelProperty("设备类型")
    @TableField("device_model")
    private String deviceModel;

    @ApiModelProperty("设备型号")
    @TableField("device_platforms")
    private String devicePlatforms;

    @ApiModelProperty("登录IP")
    @TableField("login_ip")
    private String loginIp;

    @ApiModelProperty("客户端版本")
    @TableField("version")
    private String version;

    @ApiModelProperty("创建时间")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
//    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField("create_time")
    private LocalDateTime createTime;

    @TableField("type")
    private Integer type;



    @Override
    public Serializable pkVal() {
        return this.id;
    }


    public String getDeviceId() {
        return StrUtil.sub(deviceId, 0, 50);
    }

    public String getDeviceRes() {
        return StrUtil.sub(deviceRes, 0, 10);
    }

    public String getDeviceModel() {
        return StrUtil.sub(deviceModel, 0, 32);
    }

    public String getDevicePlatforms() {
        return StrUtil.sub(devicePlatforms, 0, 64);
    }

    public String getLoginIp() {
        return StrUtil.sub(loginIp, 0, 50) ;
    }

    public String getVersion() {
        return StrUtil.sub(version, 0, 20);
    }

}
